package com.hyy.provider.controller;

import java.sql.Struct;
import java.util.List;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.hyy.common.idempotent.annotation.RepeatSubmit;
import com.hyy.common.log.annotation.Log;
import com.hyy.common.web.core.BaseController;
import com.hyy.common.mybatis.core.page.PageQuery;
import com.hyy.common.core.domain.R;
import com.hyy.common.core.validate.AddGroup;
import com.hyy.common.core.validate.EditGroup;
import com.hyy.common.log.enums.BusinessType;
import com.hyy.common.excel.utils.ExcelUtil;
import com.hyy.api.domain.provider.vo.ProvApiProgramTemplateVo;
import com.hyy.api.domain.provider.bo.ProvApiProgramTemplateBo;
import com.hyy.provider.service.IProvApiProgramTemplateService;
import com.hyy.common.mybatis.core.page.TableDataInfo;

/**
 * 上游供应商连接程序参数模板
 *
 * @author ruoyi
 * @date 2025-05-19
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/provider/apiProgramTemplate")
public class ProvApiProgramTemplateController extends BaseController {

    private final IProvApiProgramTemplateService provApiProgramTemplateService;

    /**
     * 查询上游供应商连接程序参数模板列表
     */
    @SaCheckLogin
    @GetMapping("/listByApiProgramId/{apiProgramId}")
    public List<ProvApiProgramTemplateVo> listByApiProgramId(@PathVariable("apiProgramId") Long apiProgramId ) {
        ProvApiProgramTemplateBo bo = new ProvApiProgramTemplateBo();
        bo.setApiProgramId(apiProgramId);
        List<ProvApiProgramTemplateVo> provApiProgramTemplateVos = provApiProgramTemplateService.queryList(bo);
        for (ProvApiProgramTemplateVo provApiProgramTemplateVo : provApiProgramTemplateVos) {
            String defaultValue = provApiProgramTemplateVo.getDefaultValue();
            if (StrUtil.isNotBlank(defaultValue)) {
                provApiProgramTemplateVo.setValue(defaultValue);
            }
        }


        return provApiProgramTemplateVos;
    }


}
